import { v4 as uuid } from 'uuid';
import query from './atom/db/query';

declare const action_id: string;
declare const session_id: string;
declare const spaceid: string;

function format(d: number) {
	const dt = new Date(d);
	return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate();
}

interface Message {
	exam_id: string;
}

async function atom(msg: Message) {
	const systemid = '5981';
	const { prepare, exec } = query(action_id, session_id, spaceid, systemid);
	prepare('exam_date', ['exam_id', 'exam_name', 'exam_data', 'is_deal', 'distribute_state', 'week'], { exam_id: msg.exam_id }, 0, 1, ['exam_data']);
	const [ret] = await exec();
	ret.forEach((item: any) => {
		item['exam_data_str'] = format(item['exam_data']);
	});
	return ret;
}
